<?php
namespace User\Model;

class UserInfo
{
    public $id;
    public $name;
    public $age;

    public function exchangeArray($data){
        foreach ($this as $key=>$val) {
            $this->$key = (!empty($data[$key])) ? $data[$key] : null;
        }
    }

    public function getArrayCopy() {        
        return get_object_vars($this);//返回指定对象中定义的关联数组。对象->数组，方法全舍弃
    }
}
